package com.lengchangjing.ConstructionalPatterns.SingletonPattern;

/*
    饿汉式(线程安全)
 */
public class EagerSingleton {

    private static EagerSingleton eagerSingleton = new EagerSingleton();

    private EagerSingleton() {
        System.out.println("饿汉式构造器被调用");
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public static EagerSingleton getInstance() {
        return eagerSingleton;
    }

}
